package Servlets;

import java.io.*;
import java.util.LinkedList;

import javax.servlet.http.*;

import Corpus.Corpus;
import HTMLCrators.*;
import Main.Consts;
import Main.Pair;

public class HTMLSenderServlet extends SuperServlet {

	private static final long serialVersionUID = 1L;
	private String fileName;
	
	public HTMLSenderServlet(String fileName,Corpus corpus){
		
		/*if (corpus.getLanguage()==Language.English)
			fileName+="E";
		else
			fileName+="H";*/
		
		fileName+="E";
		fileName+=".html";
		
		this.fileName=fileName;
	}
	
	public HTMLSenderServlet(String fileName){		
		this.fileName=fileName;
	}
	
	protected void buildResponse(HttpServletRequest request,
		HttpServletResponse response) throws IOException {
		
		LinkedList<Pair<String, String>> pairs=new LinkedList<Pair<String,String>>();
		pairs.add(new Pair<String, String>("[URL]",Consts.SERVER_URI));
		
		HTMLCreatorFromFile creator=new HTMLCreatorFromFileAndPairs("html\\"+fileName,pairs);
		writeResponse(response, creator);
	}

}
